import request from '@/utils/request'
import md5 from 'js-md5';


export default{

  user(dataForm) {
    dataForm.userPwd = md5(dataForm.userPwd);
    return request({
      url: `/user`,
      method: 'post',
      data:{
        userEmail:dataForm.userEmail,
        userName:dataForm.userName,
        userNum:dataForm.userNum,
        userPhone:dataForm.userPhone,
        userPwd:dataForm.userPwd,
        sitePkId:'000'
      }
    })
  },

  getUserInfo()
  {
    return request(
      {
        url: `/user/getUserVo`,
        method: 'get'
      }
    )
  },

  userSearch(pageIndex,pageSize,userNum,userName)
  {
    return request({
      url: `/user/search`,
      method: 'post',
      data:{
        pageNum:pageIndex,
        pageSize:pageSize,
        userNum:userNum,
        userName:userName
      }
    })
  },

  getUserVoByUserNum(userNum)
  {
    return request({
      url: `/user/getUserVoByUserNum?userNum=${userNum}`,
      method: 'get',
    })
  },

  getUserByUserNum(id)
  {
    return request({
      url: `/user/${id}`,
      method: 'get',
    })
  },

  getUserExtByUserNum(userNum){
    return request({
      url: `/user/getUserExtByUserNum?userNum=${userNum}`,
      method: 'get',
    })
  },

  resetPassWord(userNum)
  {
    return request({
      url: `/login/resetPassWord?userNum=${userNum}`,
      method: 'get',
    })
  },

  changePassword(userNum,userPwd,newPwd) {
    return request({
      url: `/login/changePassword`,
      method: 'post',
      data: {
        userNum,
        userPwd,
        newPwd
      }
    })
  },

  addUser(data) {
    return request({
      url: `/user`,
      method: 'post',
      data: {
        FUN_TYPE:1,
        USER_PK_ID:data.userPkId,
        USER_ACCOUNT:data.userNum,
        USER_NAME:data.userName,
        INPUT_CODE:null,
        USER_SEX:null,
        USER_EMAIL:data.userEmail,
        USER_PHONE:data.userPhone,
        USER_POST:data.userPost,
        JOB_NUM:null,
        AGENCY_PK_ID:null,
        AGENCY_NAME:null,
        AGENCY_CODE:null,
        ROLE_LIST:null,
        TYPE:data.type
      }
    })
  },

  updateUser(data) {
    return request({
      url: `/user`,
      method: 'put',
      data: {
        id:data.id,
        sitePkId:data.sitePkId,
        userEmail:data.userEmail,
        userName:data.userName,
        userNum:data.userNum,
        userPhone:data.userPhone,
        userPost:data.userPost,
        type:data.type
      }
    })
  },

  deleteUser(id)
  {
    return request({
      url: `/user/delete/${id}`,
      method: 'POST',
    })
  },

  addRole(data){
    return request({
      url: `/user/addRole`,
      method: 'post',
      data
    })
  },

  deleteRole(id){
    return request({
      url: `/user/deleteRole/${id}`,
      method: 'post',
    })
  },

}
